package com.ebs.md.container;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class ManagedObject {
    private String m_id;
    private Object m_object;
    private String m_methodName;
    private Method m_method;

    public ManagedObject() {
        m_methodName = "start";
    }

    public void setId(String id) {
        m_id = id;
    }

    public void setObject(Object object) {
        m_object = object;
    }

    public void setMethod(String methodName) {
        m_methodName = methodName;
    }

    public void execute() throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
        m_method = m_object.getClass().getDeclaredMethod(m_methodName);
        m_method.invoke(m_object);
    }

    public String toString() {
        return m_id + ", " + m_object.getClass() + ", " + m_methodName;
    }

}
